package phoenix.web.page_objects;

import org.openqa.selenium.By;
import phoenix.core.PhoenixManager;
import phoenix.core.base.extensions.PageBaseWebExt;
import phoenix.core.config.extensions.ConfigExt;
import phoenix.web.locators.base.WelcomePageLocatorsBase;

/**
 * Class provides access to web elements and actions on WelcomePage
 */
public class WelcomePage extends PageBaseWebExt
{

	/**
	 * Initializes the WelcomePage
	 * @param p_manager PhoenixManager instance
	 */
	public WelcomePage(PhoenixManager p_manager)
	{
		super(p_manager);
	}

	/**
	 * Gets web elements by site
	 * @return WelcomePageLocatorsBase instance
	 */
	public WelcomePageLocatorsBase elements()
	{
		switch (manager.testModel().getSiteName())
		{
			case ConfigExt.SITE_ID_CLICKANDFLIRT:
			{
				return new phoenix.web.locators.clickandflirt.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_LOCALSGOWILD:
			{
				return new phoenix.web.locators.localsgowild.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_EBONYFLIRT:
			{
				return new phoenix.web.locators.ebonyflirt.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_CHEECKYLOVERS:
			{
				return new phoenix.web.locators.cheekylovers.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_WILDBUDDIES:
			{
				return new phoenix.web.locators.wildbuddies.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_FLIRT:
			{
				return new phoenix.web.locators.flirt.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_FOREIGNGIRLFRIEND:
			{
				return new phoenix.web.locators.foreigngirlfriend.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_BENAUGHTY:
			{
				return new phoenix.web.locators.benaughty.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_NAUGHTYFEVER:
			{
				return new phoenix.web.locators.naughtyfever.WelcomePageLocators();
			}
			case ConfigExt.SITE_ID_MATUREDATING:
			{
				return new phoenix.web.locators.maturedating.WelcomePageLocators();
			}
			default:
			{
				return null;
			}
		}
	}

	public void waitForPageLoad()
	{
		wd().waitForVisibility(elements().blockWelcomePopup, "Block 'WelcomePopup'");
	}

	public void clickOpenResend()
	{
		wd().waitForPresence(elements().btnOpenResend, "Link 'OpenResend'");
		wd().click(elements().btnOpenResend);
	}

	public void clickResendEmail()
	{
		wd().waitForPresence(elements().btnResendEmail, "Link 'Resend email'");
		wd().click(elements().btnResendEmail);
	}

	public void clickChangeEmail()
	{
		wd().waitForVisibility(elements().btnChangeEmail, "Link change email");
		wd().click(elements().btnChangeEmail);
	}

	public void setChangeEmail(String p_value)
	{
		wd().waitForVisibility(elements().inputChangeEmail, "Input email");
		wd().clear(elements().inputChangeEmail);
		wd().type(elements().inputChangeEmail, p_value);
	}

	public void submitChangeEmail()
	{
		wd().waitForVisibility(elements().btnSubmit, "Submit button");
		wd().click(elements().btnSubmit);
	}

	public void waitForResendNotification()
	{
		wd().waitForVisibility(elements().blockResendNotification, "Block 'Resend notification'");
	}
}